cc.Class({
	extends: cc.Component,

	properties: {
		topNode: {
			default: null,
			type: cc.Node
		},

		realplayer: {
			default: null,
			type: cc.Node
		},

		nexttools: {
			default: null,
			type: cc.Node
		},

	},
	//显示升级界面--预制体
	showTip: function(event, customEventData) {


		var CanvasNode = this.topNode;

		if (!CanvasNode) {
			cc.log('find Canvas error');
			return;
		}
		if (step != 8) {

			var onResourceLoaded = function(errorMessage, loadedResource) {

				if (errorMessage) {
					cc.log('Prefab error:' + errorMessage);
					return;
				}
				if (!(loadedResource instanceof cc.Prefab)) {
					cc.log('Prefab error');
					return;
				}

				var newMyPrefab = cc.instantiate(loadedResource);

				CanvasNode.addChild(newMyPrefab, 100);

				newMyPrefab.setPosition(0, 0);

				var newMyPrefabScript = newMyPrefab.getComponent('AlertMsg');



				newMyPrefabScript.setLabelString(errormsg);


			};

			if (isShow == 0) {
				isShow = !isShow;
				cc.resources.load('AlertMsg', onResourceLoaded);

			}
		} else {
			// var anim = this.realplayer.getComponent(cc.Animation);
			// var animState = anim.play('step1');
			// anim.pause('step1');
			var that = this;


			const sendData = {
				"TaskGuid": "slkdjflie09876",
				"DataType": "usergy",
				"userid": "1"
			}

			//获取网络数据
			let xhr = new XMLHttpRequest();
			xhr.onreadystatechange = function() {
				if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
					var response = xhr.responseText;
					//console.log(response);
					//console.log("==============");
					let info = eval('(' + response + ')');
					let infores = eval('(' + info + ')');
					stepstatus = infores.status;

					waittime = infores.setlog.waittime;
					waitminutes = infores.setlog.waitminutes;





					//
					if (stepstatus == 0) {
						var onResourceLoaded = function(errorMessage, loadedResource) {
							if (errorMessage) {
								cc.log('Prefab error:' + errorMessage);
								return;
							}
							if (!(loadedResource instanceof cc.Prefab)) {
								cc.log('Prefab error');
								return;
							}


							var newMyPrefab = cc.instantiate(loadedResource);

							CanvasNode.addChild(newMyPrefab, 100);

							newMyPrefab.setPosition(0, 0);

							var newMyPrefabScript = newMyPrefab.getComponent('Alert');

							newMyPrefabScript.setLabelString("开始蒸馏！");

							newMyPrefabScript.onConfirBtn(function() {

								//cc.log('开始粉碎');
								//获取数据
								const sendData = {
									"TaskGuid": "slkdjflie09876",
									"DataType": "gameset",
									"user_id": "1",
									"set_code": "8",
									"status": "1"
								};

								cc.log(sendData);
								//获取网络数据
								let xhr = new XMLHttpRequest();
								xhr.onreadystatechange = function() {
									if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
										var response = xhr.responseText;
										cc.log(response);
										//console.log("==============");	
										let info = eval('(' + response + ')');
										let infores = eval('(' + info + ')');


										cc.log(infores);

									}
								};

								// xhr.open("GET", seturl+'/'+JSON.stringify(sendData), true);
								xhr.open("GET", seturl + JSON.stringify(sendData), true);
								xhr.send();

							});
						};
						if (isShow == 0) {
							isShow = !isShow;
							cc.resources.load('Alert', onResourceLoaded);
						}

					} else {



						if (waitminutes < 0 || waitminutes == 0) {

							//======
							var onResourceLoaded = function(errorMessage, loadedResource) {
								if (errorMessage) {
									cc.log('Prefab error:' + errorMessage);
									return;
								}
								if (!(loadedResource instanceof cc.Prefab)) {
									cc.log('Prefab error');
									return;
								}


								var newMyPrefab = cc.instantiate(loadedResource);

								CanvasNode.addChild(newMyPrefab, 100);

								newMyPrefab.setPosition(0, 0);

								var newMyPrefabScript = newMyPrefab.getComponent('Alert');

								newMyPrefabScript.setLabelString("好的，恭喜完成！");

								newMyPrefabScript.onConfirBtn(function() {

									step = 9;

									//获取数据
									const sendData = {
										"TaskGuid": "slkdjflie09876",
										"DataType": "gameset",
										"user_id": "1",
										"set_code": "8",
										"status": "2"
									};

									cc.log(sendData);
									//获取网络数据
									let xhr = new XMLHttpRequest();
									xhr.onreadystatechange = function() {
										if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status < 400)) {
											var response = xhr.responseText;
											cc.log(response);
											//console.log("==============");	
											let info = eval('(' + response + ')');
											let infores = eval('(' + info + ')');


											cc.log(infores);

										}
									};

									// xhr.open("GET", seturl+'/'+JSON.stringify(sendData), true);
									xhr.open("GET", seturl + JSON.stringify(sendData), true);
									xhr.send();



								});
							};


							if (isShow == 0) {
								isShow = !isShow;
								cc.resources.load('Alert', onResourceLoaded);

							}
							//======


						} else {

							var onResourceLoaded = function(errorMessage, loadedResource) {

								if (errorMessage) {
									cc.log('Prefab error:' + errorMessage);
									return;
								}
								if (!(loadedResource instanceof cc.Prefab)) {
									cc.log('Prefab error');
									return;
								}

								var newMyPrefab = cc.instantiate(loadedResource);

								CanvasNode.addChild(newMyPrefab, 100);

								newMyPrefab.setPosition(0, 0);

								var newMyPrefabScript = newMyPrefab.getComponent('AlertMsg');



								newMyPrefabScript.setLabelString('倒计时:' + waittime);


							};
							if (isShow == 0) {
								isShow = !isShow;
								cc.resources.load('AlertMsg', onResourceLoaded);
							} //cc.loader.loadRes('background', onResourceLoaded );
						}
					}
				}
			};

			// xhr.open("GET", seturl+'/'+JSON.stringify(sendData), true);
			xhr.open("GET", url + JSON.stringify(sendData), true);
			xhr.send();
			//===================================
		}

	},
	// LIFE-CYCLE CALLBACKS:

	// onLoad () {},

	start() {

	},

	// update (dt) {},
});
